package com.lili.order.controller.order;

import com.lili.common.result.Result;
import com.lili.model.order.entity.order.OrderDetail;

import com.lili.order.service.order.OrderDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *  用户信息管理
 */
@Api(tags = "订单明细管理")
@RestController
@RequestMapping("/admin/order/orderDetail")
public class OrderDetailController {

    @Autowired
    private OrderDetailService orderDetailService;
    @ApiOperation("添加订单明细")
    @PostMapping("/save")
    public Result saveOrder(@RequestBody OrderDetail orderDetail){
        int rs= orderDetailService.save(orderDetail);
        return rs==1? Result.ok():Result.fail();

    }
    @ApiOperation("删除订单明细")
    @DeleteMapping("/delete")
    public Result deleteOrderDetail(String sn){
        int rs= orderDetailService.deleteBySn(sn);
        return rs==1? Result.ok():Result.fail();

    }
    @ApiOperation("修改订单明细")
    @PutMapping("/update")
    public Result updateOrderDetail(@RequestBody OrderDetail orderDetail){
        int rs= orderDetailService.updateBySn(orderDetail);
        return rs==1? Result.ok():Result.fail();

    }
    @ApiOperation("永久删除订单明细")
    @DeleteMapping("/deleteForever")
    public Result deleteOrderDetailForever(String sn){
        int rs= orderDetailService.deleteForever(sn);
        return rs==1? Result.ok():Result.fail();

    }
    @ApiOperation("根据sn订单明细")
    @GetMapping("/getBySn")
    public Result getAllOrderBySn(String sn){
        OrderDetail orderDetail = orderDetailService.getOrderBySn(sn);
        return Result.ok(orderDetail);
    }


}
